/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Views;

import Classes.Imprimante;
import Classes.Materiel;
import Classes.Retroprojecteur;
import Classes.Salle;
import Classes.Secteur;
import DAO.DBConnect;
import DAO.ImprimanteDAO;
import DAO.MaterielDAO;
import DAO.RetroprojecteurDAO;
import DAO.SalleDAO;
import DAO.SecteurDAO;
import DAO.TypeDAO;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.Map;
import javax.swing.JFrame;

/**
 *
 * @author Kévin
 */
public class vueGlobale extends javax.swing.JFrame {

    TypeDAO tDAO = new TypeDAO(DBConnect.getInstance());
    SecteurDAO sDAO = new SecteurDAO(DBConnect.getInstance());
    MaterielDAO mDAO = new MaterielDAO(DBConnect.getInstance());
    SalleDAO salleDAO = new SalleDAO(DBConnect.getInstance());
    RetroprojecteurDAO rDAO = new RetroprojecteurDAO(DBConnect.getInstance());
    ImprimanteDAO iDAO = new ImprimanteDAO(DBConnect.getInstance());
    Map<Integer, Classes.Type>listeType = tDAO.findAll();
    Map<Integer, Secteur>listeSecteur = sDAO.findAll();
    Map<Long, Materiel>listeMateriel = mDAO.findAll();
    Map<Integer, Salle>listeSalle = salleDAO.findAll();
    Map<Long, Retroprojecteur>listeRetroprojecteur = rDAO.findAll();
    Map<Long, Imprimante>listeImprimante = iDAO.findAll();
    
    /**
     * Creates new form vueGlobale
     */
    public vueGlobale() {
        initComponents();

        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((dimension.getWidth() - this.getWidth()) / 2);
        int y = (int) ((dimension.getHeight() - this.getHeight()) / 2);
        this.setLocation(x, y);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        BTN_SearchBC = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jLabel1.setText("Bienvenue sur la gestion des matériels");

        jButton1.setText("Gérer les Ordinateurs");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Gérer les rétroprojecteurs");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Gérer les imprimantes");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("Autres matériels");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("Importer inventaire");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("Recherche par salle");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        BTN_SearchBC.setText("Recherche par CB ");
        BTN_SearchBC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BTN_SearchBCActionPerformed(evt);
            }
        });

        jButton7.setText("Recherche Multiple");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel1)
                        .addGap(103, 103, 103))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(BTN_SearchBC, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jButton6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(23, 23, 23))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton3)
                    .addComponent(jButton4))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton5)
                    .addComponent(jButton6))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BTN_SearchBC)
                    .addComponent(jButton7))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Ouverture de la fenêtre Ordinateur
     * @param evt 
     */
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        JFrame openFrame = new vueOrdinateur(this);
        openFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        openFrame.setVisible(true);
        this.setVisible(false);

        openFrame.pack();
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * Ouverture de la fenêtre Rétroprojecteur
     * @param evt 
     */
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        JFrame openFrame = new vueRetroprojecteur(this, listeType, listeSecteur, listeRetroprojecteur);
        openFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        openFrame.setVisible(true);
        this.setVisible(false);

        openFrame.pack();
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
     * Ouverture de la fenêtre Inmprimante
     * @param evt 
     */
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        JFrame openFrame = new VUEImprimante(this, listeType, listeSecteur, listeImprimante);
        openFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        openFrame.setVisible(true);
        this.setVisible(false);

        openFrame.pack();
    }//GEN-LAST:event_jButton3ActionPerformed

    /**
     * Ouverture de la fenêtre Matériel
     * @param evt 
     */
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        JFrame openFrame = new vueAutre(this, listeType, listeSecteur, listeMateriel);
        openFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        openFrame.setVisible(true);
        this.setVisible(false);

        openFrame.pack();
    }//GEN-LAST:event_jButton4ActionPerformed

    /**
     * Ouverture de la fenêtre d'importation d'un fichier
     * @param evt 
     */
    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        JFrame openFrame = new vueImportList(this, listeSalle);
        openFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        openFrame.setVisible(true);
        this.setVisible(false);

        openFrame.pack();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
    }//GEN-LAST:event_formWindowOpened

    /**
     * Ouverture de la fenêtre de Recherche par Salle
     * @param evt 
     */
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        JFrame openFrame = new vueRecherche(this);
        openFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        openFrame.setVisible(true);
        this.setVisible(false);

        openFrame.pack();
    }//GEN-LAST:event_jButton6ActionPerformed

    /**
     * Ouverture de la fenêtre de recherche par Code Barre
     * @param evt 
     */
    private void BTN_SearchBCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BTN_SearchBCActionPerformed
        JFrame openFrame = new vueRechercheCodeBarre(this);
        openFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        openFrame.setVisible(true);
        this.setVisible(false);

        openFrame.pack();
    }//GEN-LAST:event_BTN_SearchBCActionPerformed

    /**
     * Ouverture de la fenêtre de recherche multiple
     * @param evt 
     */
    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        JFrame openFrame = new vueRechercheMultiple(this);
        openFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        openFrame.setVisible(true);
        this.setVisible(false);

        openFrame.pack();
    }//GEN-LAST:event_jButton7ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BTN_SearchBC;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
}
